package com.yx.demo

import android.content.Context
import android.media.AudioManager
import android.media.SoundPool


class SoundManager(var context: Context) {

    private val soundPool: SoundPool = SoundPool(10, AudioManager.STREAM_MUSIC, 0)
    private val soundMap: HashMap<Int, Int> = HashMap()

    init {
        soundMap[1] = soundPool.load(context, R.raw.beep, 1);
    }

    /**
     * 刷卡的声音
     */
    fun playBeep() {
        soundMap[1]?.let { soundPool.play(it, 1F, 1F, 0, 0, 1F) }
    }


    fun release(){
        soundPool.release()
    }
}